// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.CrossClusterReplication;

public sealed partial class ForgetFollowerRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Removes the follower retention leases from the leader.
/// </para>
/// </summary>
public sealed partial class ForgetFollowerRequest : PlainRequest<ForgetFollowerRequestParameters>
{
	public ForgetFollowerRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationForgetFollower;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ccr.forget_follower";

	[JsonInclude, JsonPropertyName("follower_cluster")]
	public string? FollowerCluster { get; set; }
	[JsonInclude, JsonPropertyName("follower_index")]
	public Elastic.Clients.Elasticsearch.IndexName? FollowerIndex { get; set; }
	[JsonInclude, JsonPropertyName("follower_index_uuid")]
	public string? FollowerIndexUuid { get; set; }
	[JsonInclude, JsonPropertyName("leader_remote_cluster")]
	public string? LeaderRemoteCluster { get; set; }
}

/// <summary>
/// <para>
/// Removes the follower retention leases from the leader.
/// </para>
/// </summary>
public sealed partial class ForgetFollowerRequestDescriptor<TDocument> : RequestDescriptor<ForgetFollowerRequestDescriptor<TDocument>, ForgetFollowerRequestParameters>
{
	internal ForgetFollowerRequestDescriptor(Action<ForgetFollowerRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

	public ForgetFollowerRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
	{
	}

	public ForgetFollowerRequestDescriptor() : this(typeof(TDocument))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationForgetFollower;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ccr.forget_follower";

	public ForgetFollowerRequestDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.IndexName index)
	{
		RouteValues.Required("index", index);
		return Self;
	}

	private string? FollowerClusterValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexName? FollowerIndexValue { get; set; }
	private string? FollowerIndexUuidValue { get; set; }
	private string? LeaderRemoteClusterValue { get; set; }

	public ForgetFollowerRequestDescriptor<TDocument> FollowerCluster(string? followerCluster)
	{
		FollowerClusterValue = followerCluster;
		return Self;
	}

	public ForgetFollowerRequestDescriptor<TDocument> FollowerIndex(Elastic.Clients.Elasticsearch.IndexName? followerIndex)
	{
		FollowerIndexValue = followerIndex;
		return Self;
	}

	public ForgetFollowerRequestDescriptor<TDocument> FollowerIndexUuid(string? followerIndexUuid)
	{
		FollowerIndexUuidValue = followerIndexUuid;
		return Self;
	}

	public ForgetFollowerRequestDescriptor<TDocument> LeaderRemoteCluster(string? leaderRemoteCluster)
	{
		LeaderRemoteClusterValue = leaderRemoteCluster;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(FollowerClusterValue))
		{
			writer.WritePropertyName("follower_cluster");
			writer.WriteStringValue(FollowerClusterValue);
		}

		if (FollowerIndexValue is not null)
		{
			writer.WritePropertyName("follower_index");
			JsonSerializer.Serialize(writer, FollowerIndexValue, options);
		}

		if (!string.IsNullOrEmpty(FollowerIndexUuidValue))
		{
			writer.WritePropertyName("follower_index_uuid");
			writer.WriteStringValue(FollowerIndexUuidValue);
		}

		if (!string.IsNullOrEmpty(LeaderRemoteClusterValue))
		{
			writer.WritePropertyName("leader_remote_cluster");
			writer.WriteStringValue(LeaderRemoteClusterValue);
		}

		writer.WriteEndObject();
	}
}

/// <summary>
/// <para>
/// Removes the follower retention leases from the leader.
/// </para>
/// </summary>
public sealed partial class ForgetFollowerRequestDescriptor : RequestDescriptor<ForgetFollowerRequestDescriptor, ForgetFollowerRequestParameters>
{
	internal ForgetFollowerRequestDescriptor(Action<ForgetFollowerRequestDescriptor> configure) => configure.Invoke(this);

	public ForgetFollowerRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.CrossClusterReplicationForgetFollower;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ccr.forget_follower";

	public ForgetFollowerRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index)
	{
		RouteValues.Required("index", index);
		return Self;
	}

	private string? FollowerClusterValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexName? FollowerIndexValue { get; set; }
	private string? FollowerIndexUuidValue { get; set; }
	private string? LeaderRemoteClusterValue { get; set; }

	public ForgetFollowerRequestDescriptor FollowerCluster(string? followerCluster)
	{
		FollowerClusterValue = followerCluster;
		return Self;
	}

	public ForgetFollowerRequestDescriptor FollowerIndex(Elastic.Clients.Elasticsearch.IndexName? followerIndex)
	{
		FollowerIndexValue = followerIndex;
		return Self;
	}

	public ForgetFollowerRequestDescriptor FollowerIndexUuid(string? followerIndexUuid)
	{
		FollowerIndexUuidValue = followerIndexUuid;
		return Self;
	}

	public ForgetFollowerRequestDescriptor LeaderRemoteCluster(string? leaderRemoteCluster)
	{
		LeaderRemoteClusterValue = leaderRemoteCluster;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(FollowerClusterValue))
		{
			writer.WritePropertyName("follower_cluster");
			writer.WriteStringValue(FollowerClusterValue);
		}

		if (FollowerIndexValue is not null)
		{
			writer.WritePropertyName("follower_index");
			JsonSerializer.Serialize(writer, FollowerIndexValue, options);
		}

		if (!string.IsNullOrEmpty(FollowerIndexUuidValue))
		{
			writer.WritePropertyName("follower_index_uuid");
			writer.WriteStringValue(FollowerIndexUuidValue);
		}

		if (!string.IsNullOrEmpty(LeaderRemoteClusterValue))
		{
			writer.WritePropertyName("leader_remote_cluster");
			writer.WriteStringValue(LeaderRemoteClusterValue);
		}

		writer.WriteEndObject();
	}
}